﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RobotsSample
{
    public class Sample_SpiderRobot : RobotSampleAbstract
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="defaultIds">T:L1,T:L1,T:L3,T:L3,T:R1,T:R1,T:R3,T:R3</param>
        /// <returns></returns>
        public override bool Run(string ip, int port, byte[] defaultIds = null)
        {
            var isSuccess = base.Run(ip, port, defaultIds);
            if (!isSuccess)
            {
                return false;
            }

            var ids = IdsNPlace.Select(p => (byte)p.Item1).ToArray();

            Id = MiniBotAlgorithmLib.AddRobot((int)RobotTypeEnum.Spider, ids, ids.Length);
            var rs = MiniBotAlgorithmLib.BindRobotModuleApis(Id, SetPositionCallback, SetPositionWithSpeedCallback, SetMultiPositionCallback,
                    SetMultiPositionWithSpeedCallback, SetSpeedCallback, SetRunningSpeedCallback, SetTorqueEnableCallback, SetModeCallback);

            return rs;
        }
    }
}
